export function debounce(fn, delay=1000) {
	let timer = null
	const _debounce = function(...args) {
		return new Promise((resolve) => {
			if(timer){ 
				clearTimeout(timer)
				timer = null
			}
			timer = setTimeout(() => {
				const result = fn.apply(this, args)
				resolve(result)
			}, delay);
		})
	}
	return _debounce
}